package easy;

public class Solution_1768 {

    public String mergeAlternately(String word1, String word2) {
        int index = 0;
        char[] chars = new char[word1.length() + word2.length()];
        int length = Math.min(word1.length(), word2.length());
        for (int i = 0; i < length; i++) {
            chars[index++] = word1.charAt(i);
            chars[index++] = word2.charAt(i);
        }
        if (word1.length() > word2.length()) {
            for (int i = length; i < word1.length(); i++) {
                chars[index++] = word1.charAt(i);
            }
        } else {
            for (int i = length; i < word2.length(); i++) {
                chars[index++] = word2.charAt(i);
            }
        }
        return new String(chars);
    }
}
